#include <iostream>
using std::cout;
using std::endl;
class Point{
public:
    Point(int x, int y)
    :_x(x)
    ,_y(y)
    {
        cout << "Point(int,int)" << endl;
    }
    Point(const Point & rhs)
    :_x(rhs._x)
    ,_y(rhs._y)
    {
        cout << "Point(const Point &)" << endl;
    }
    void print(){
        cout << "(" << _x << "," << _y << ")";
    }

private:
    int _x;
    int _y;
};

class Line{
public:
    //注意此时初始化列表中的写法
    //形参和实参相结合，2次
    Line(Point p1, Point p2)
    :_pt1(p1)// Point _pt1 = p1
             // 也有两次
    ,_pt2(p2)
    {

    }

    void printLine(){
        _pt1.print();
        cout << "----->";
        _pt2.print();
    }


private:
    Point _pt1;
    Point _pt2;
};



void test(){
    Point pt1(1, 2), pt2(3, 4);
    Line line(pt1, pt2);
    line.printLine();
}

int main()
{
    test();
    return 0;
}

